package de.SiSoft.pendlerpad.view;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageButton;
import android.widget.TextView;
import de.SiSoft.pendlerpad.R;

public class WorktimeFragment extends Fragment {

    boolean isActive = false;

    ImageButton imageButton;
    boolean isPressed = false;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
	    Bundle savedInstanceState) {

	View rootView = inflater.inflate(R.layout.worktime_fragment, container,
		false);
	imageButton = (ImageButton) rootView
		.findViewById(R.id.toggleWorktimeButton);
	addListenerOnButton();
	return rootView;
    }

    public void addListenerOnButton() {
	imageButton.setOnClickListener(new OnClickListener() {

	    @Override
	    public void onClick(View view) {
		if (!isActive) {
		    ((ImageButton) view).setImageResource(R.drawable.play);
		} else {
		    ((ImageButton) view).setImageResource(R.drawable.stop);
		}
		isActive = !isActive;
	    }
	});
    }
}
